package com.jiujichina.base;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @author liyi
 * @title: ResultData
 * @package com.homedo.core.common.base.dto
 * @date 2018/1/19 13:57
 */

@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class ResultData {
    @ApiModelProperty(value = "代码值")
    private int code;

    @ApiModelProperty(value = "提示信息")
    private String msg;

    @ApiModelProperty(value = "数据")
    private Object data;

    public ResultData() {
    }

    public ResultData(int code,Object data) {
        this.code = code;
        this.data = data;
    }

    public ResultData(String msg,Object data) {
        this.msg = msg;
        this.data = data;
    }

    public ResultData(Meta meta, Object data) {
        this.code = meta.getCode();
        this.msg = meta.getMsg();
        this.data = data;

    }

    public ResultData(Meta meta) {
        this.code = meta.getCode();
        this.msg = meta.getMsg();
    }

    public static ResultData newInstance() {
        return new ResultData(Meta.CODE_200);
    }

    public static ResultData newInstance(Object data) {
        return ResultData.newInstance(Meta.CODE_200, data);
    }
    public static ResultData newInstance(Meta meta, Object data) {
        return new ResultData(meta, data);
    }
}
